<template>
	<view>
		<view>
			<!-- 左侧通讯录 -->
			<scroll-view class="scroll-container" scroll-y="true" :scroll-into-view="toView" v-if="isShow"
				scroll-with-animation="true">
				<view class="name-text-view" @click="NOLimiClick()">不限</view>
				<view v-for="(item, index) in locationDataList" :key="index" :id="item.key">
					<view @click="click_item(item)">
						<view class="name-text-view">{{ item.name }}</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		getAddressMarketList
	} from '@/api/base.js'
	export default {
		data() {
			return {
				temp: 0,
				toView: '',
				commonLocation: [],
				locationDataList: [],
				registration_province: '', //省name
				registration_province_id: '', //省id
				isShow: true,
			}
		},
		onLoad(option) {
			if (option.economize_id) {
				//获取省数据
				var that = this
				this.registration_province_id = option.economize_id
				this.registration_province = option.registration_province
				getAddressMarketList(option.economize_id).then(res => {
					that.isShow = false
					if (res.code == 0) {
						that.locationDataList = res.data
						that.$forceUpdate()
						that.isShow = true
					}
				})
			}
		},
		methods: {
			toSelectIndex(item, index) {
				this.toView = item
				this.temp = index
			},
			click_item(item) {
				item.registration_province_id = this.registration_province_id
				item.registration_province = this.registration_province
				this.Backhaul(item)
			},
			commonClick(item) {
				item.registration_province_id = this.registration_province_id
				item.registration_province = this.registration_province
				this.Backhaul(item)
			},
			NOLimiClick() {
				var item = {}
				item.registration_province_id = this.registration_province_id
				item.registration_province = this.registration_province
				item.name = '不限'
				this.Backhaul(item)
			},
			Backhaul(obj) {
				// 获取当前页上的栈（数组形式）
				var pages = getCurrentPages()
				//上上一页面 
				var prevPage = pages[pages.length - 3]
				obj.type = 'region'
				prevPage.$vm.backData(obj) /// backData为A页面定义好的一个方法 调用该方法obj数据会返回到A页面backData方法中
				// 返回上上一页
				uni.navigateBack({
					delta: 2
				})
			}


		}
	}
</script>

<style lang="scss" scoped>
	.content-item-view {
		width: 134rpx;
		height: 54rpx;
		background: #F4F4F499;
		border-radius: 28rpx;
		text-align: center;
		margin-right: 20rpx;
	}

	.name-text {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		line-height: 54rpx;
		color: #333333;
		opacity: 1;
	}

	.common-key-text {
		width: 100%;
		height: 58rpx;
		background: #1D212505;
		border-radius: 0rpx;
		line-height: 58rpx;
		padding-left: 28rpx;
	}

	.common-text-view {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		opacity: 1;
	}

	.scroll-view-class {
		white-space: nowrap;
		background-color: white;
		height: auto;
	}

	.scroll-view-class-box {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.content-item-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.scroll-container {
		height: 100vh;
	}

	.letter-nav {
		position: fixed;
		right: 25px;
		top: 90px;
	}

	.image-view {
		width: 60rpx;
		height: auto;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 22rpx;
	}

	.common-text {
		font-size: 32rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #1C2125;
		opacity: 1;
	}



	.name-text-view {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #000000;
		padding: 30rpx 28rpx;
		box-sizing: border-box;
		background-color: #FFFFFF;
		border-bottom: 1rpx solid #E6E6E6;
	}


	.pad28-8-6 {
		padding: 8rpx 0px 6rpx 28rpx;
	}

	.pad28 {
		padding: 22rpx 28rpx;
	}

	.margin28 {
		margin: 28rpx;
	}

	.bac-F4 {
		background-color: #F4F4F4;
	}

	.right-view-text {
		font-size: 32rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #999999;
	}

	.right-view-text-select {
		font-size: 32rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #0E59EA;
	}
</style>